package com.hc.sensitive.config;

import com.hc.sensitive.ac.ACTrie;
import com.hc.sensitive.factory.TxtWordFactory;
import com.hc.sensitive.filter.ACFilter;
import com.hc.sensitive.filter.TrieFilter;
import com.hc.sensitive.sensitiveword.SensitiveWordBs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 选择敏感词过滤方法
 */
@Configuration
public class SensitiveWordConfig {

    @Autowired
    private TxtWordFactory wordFactory;

    /**
     * 设置敏感词策略，敏感词词库
     *
     * @since 1.0.0
     */
    @Bean
    public SensitiveWordBs sensitiveWordBs() {
        return SensitiveWordBs.newInstance()
                .filterStrategy(ACFilter.getInstance())
                .sensitiveWord(wordFactory)
                .init();
    }

}